package com.yzc.controller;

import com.yzc.model.vo.order.RushOrdersVo;
import com.yzc.result.Result;
import com.yzc.result.ResultCodeEnum;
import com.yzc.service.TOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

import static com.yzc.result.ResultCodeEnum.BAD_REQUEST;


@RestController
@RequestMapping("/order")
public class RushOrdersController {
    @Autowired
    private TOrdersService tOrdersService;

    @GetMapping("/rushOrdersList")
    public Result<List<RushOrdersVo>> rushOrdersList() {
        return Result.success(tOrdersService.rushOrdersList());
    }

    @GetMapping("/rushOrderByVersion")
    public Result rushOrderByVersion(@RequestParam("id") Integer id,
                                         @RequestParam("userId") Integer userId) {
        try {
            tOrdersService.rushOrderByVersion(id, userId);
            return Result.success();
        }catch (Exception e) {
            return Result.fail(BAD_REQUEST);
        }

    }

}
